package com.example.entity;

import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Property;
import org.springframework.data.neo4j.core.schema.Relationship;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import static org.springframework.data.neo4j.core.schema.Relationship.Direction.INCOMING;
import static org.springframework.data.neo4j.core.schema.Relationship.Direction.OUTGOING;

/**
 *
 */
@Node("Year")
public class Year implements Serializable, Comparable<Year> {
    @Id
    @GeneratedValue
    private Long id;

    @Property("year")
    private String year;

    @Property("logic_id")
    private String logicId;

    @Relationship(type = "GuanXi", direction = OUTGOING)
    private Set<GuanXi_YM> guanXi_ymSet = new HashSet<>();


    // constructor
    public Year(String year, String logicId) {
        this.year = year;
        this.logicId = logicId;
    }

    // getter and setter
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getYear() {
        return year;
    }

    public void setYear(String year) {
        this.year = year;
    }

    public String getLogicId() {
        return logicId;
    }

    public void setLogicId(String logicId) {
        this.logicId = logicId;
    }

    public Set<GuanXi_YM> getGuanXi_ymSet() {
        return guanXi_ymSet;
    }

    public void setGuanXi_ymSet(Set<GuanXi_YM> guanXi_ymSet) {
        this.guanXi_ymSet = guanXi_ymSet;
    }

    public void addGuanXi_ym(GuanXi_YM guanXi_ym) {
        guanXi_ymSet.add(guanXi_ym);
    }

    @Override
    public int compareTo(Year y) {
        int i =  Integer.valueOf(this.getYear()) - Integer.valueOf(y.getYear()) ;//先按照年排序
//        if(i == 0){
//            return this.score - o.getScore();//如果年龄相等了再用分数进行排序
//        }
        return i;
    }
}
